/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: jse2204 - Demo
 * <p>Powered by webrx On 2022-10-08 11:11:22
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Demo {
    public static void main(String[] args) {
        //System.out.printf("%16s  %6d%n","a",203453);
        //System.out.printf("%16s  %6d%n","aaaaaaaaaa",15);
        //System.out.printf("%16s  %6d%n","csfsf",35);

        System.out.println(center("hello", 26, " "));
        System.out.println(center("he", 26, " "));
        System.out.println(center("heaasdo", 26, " "));
    }

    public static String left(String str, int length) {
        return String.format("%-" + length + "s", str);
    }

    public static String right(String str, int length) {
        return String.format("%" + length + "s", str);
    }


    public static String center(String str, int length, String ch) {
        int size = (length - str.length()) / 2;
        return ch.repeat(size).concat(str).concat(ch.repeat(size));

    }

}
